package com.stars.module.department.mapper;

import com.github.yulichang.base.MPJBaseMapper;
import com.stars.module.department.entity.StarDept;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author : DepartMentMapper
 * @version : 1.0
 * @date : 2022/10/31 11:22
 * @description : 部门映射
 */
@Mapper
public interface StarDeptMapper extends MPJBaseMapper<StarDept> {

    @Select("SELECT O.*,UN.ORGNAME AS UNITNAME FROM STAR_ORGANIZES O LEFT JOIN STAR_ORGUSER OU ON O.ID = OU.ORG_ID LEFT JOIN STAR_ORGANIZES UN ON O.UNIT_ID = UN.ID WHERE OU.USER_ID = #{userId} AND OU.IS_MAIN = 1 AND O.ROWSTATUS > -1")
    StarDept loadUserMainDept(String userId);

}
